<template>
    <div class="printWrap" ref="printWrap">
        <Button class="btn" type="primary" @click="onDownLoad">{{$t('下载')}}</Button>
        <Button class="btn" type="primary" @click="onPrint">{{$t('打印')}}</Button>
    </div>
</template>

<script>
// import {printPage} from './print'
// removeIeHeaderAndFooter()
// import htmlToPdf from '@/util/htmToPdf'
import useCompToPDF from '@/util/useCompToPDF'

let exportPDF = null;
export default {
    name: "wrap",
    props: ['type'],
    mounted() {
        const obj = {
            'CAT': this.$t('交付验收'),
            'SAT': this.$t('供应商处预验收'),
            'FAT': this.$t('最终验收'),
            'SOC': this.$t('确定供应商'),
            'PAY1': this.$t('支付首期款'),
            'PAY2': this.$t('第二次付款'),
            'PAY3': this.$t('第三次付款'),
            'CAP': this.$t('转固'),
        }
        this.$nextTick(()=>{
             exportPDF = useCompToPDF({fileName:obj[this.type]})
        })
    },
    methods: {
        onPrint() {
            window.print()

        },
        onDownLoad() {

            exportPDF(document.getElementById('printWrapId'))
             // htmlToPdf('printWrapId',)
        }
    }
}
</script>

<style scoped lang="scss">
.printWrap {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 16px;
    background: rgba(71, 71, 71, 1);
    //box-shadow: inset 0 1px 1px rgb(0,0,0,.15), inset 0 -1px 0 rgb(255, 255, 255,.05), 0 1px 0rgb(0, 0, 0,.15), 0 1px 1px rgb(0, 0, 0, .1);
    text-align: right;
    z-index: 11;

    .btn {
        margin-left: 16px;
    }
}

@media print {
    .printWrap {
        display: none;
    }
}
</style>
